<template>
  <!-- 只在非管理后台路由显示Navbar和Footer -->
  <Navbar v-if="!isAdminRoute" />
  <div :class="{'container': !isAdminRoute}">
    <router-view v-slot="{ Component }">
      <transition name="fade" mode="out-in">
        <component :is="Component" />
      </transition>
    </router-view>
  </div>
  <Footer v-if="!isAdminRoute" />
</template>

<script>
import Navbar from './components/layout/Navbar.vue'
import Footer from './components/layout/Footer.vue'
import ThemeToggle from './components/ui/ThemeToggle.vue'
import themeService from './services/themeService'
import { computed } from 'vue'
import { useRoute } from 'vue-router'

export default {
  name: 'App',
  components: {
    Navbar,
    Footer,
    ThemeToggle
  },
  setup() {
    const route = useRoute()
    
    // 判断当前是否为管理后台路由
    const isAdminRoute = computed(() => {
      return route.path.startsWith('/admin')
    })
    
    return {
      isAdminRoute
    }
  },
  mounted() {
    // 初始化主题
    themeService.initTheme()
  }
}
</script>

<style>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 15px;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .container {
    padding: 20px 40px;
  }
}
</style> 